﻿using System;
using System.Data.SqlClient;
using System.Windows.Forms;
using Elkomp;

namespace MedicinskiUslugi {

	public partial class frmIzvrsiteli : FormaBrowse {
		SqlConnection con = new SqlConnection();
		SqlCommand com = new SqlCommand();

		public frmIzvrsiteli() {
			InitializeComponent();
			btnOk.Visible = false;
		}

		public frmIzvrsiteli( bool zoom ) {
			InitializeComponent();
			btnOk.Visible = true;
			zoom = true;
		}

		private void SelcectionCHanged( object sender, EventArgs e ) {
			if ( this.tblIzvrsiteliGrid.CurrentRow != null ) {
				dr = this.medicinskiUslugiDataSet.tblIzvrsiteli[this.tblIzvrsiteliGrid.CurrentRow.Index];
			}
		}

		public override void NovZapis( object sender, EventArgs e ) {
			this.tblIzvrsiteliGrid.Insert();
			base.NovZapis( sender, e );
		}

		public override void IzmeniZapis( object sender, EventArgs e ) {
			this.tblIzvrsiteliGrid.Edit();
			base.IzmeniZapis( sender, e );
		}

		private void frmIzvrsiteli_Load( object sender, EventArgs e ) {
			Navigator.BindingSource = tblIzvrsiteliBindingSource;
			this.tblIzvrsiteliTableAdapter.Fill( this.medicinskiUslugiDataSet.tblIzvrsiteli );
		}

		private void btnPrebaraj_Click( object sender, EventArgs e ) {
			this.tblIzvrsiteliTableAdapter.Fill( this.medicinskiUslugiDataSet.tblIzvrsiteli );
			this.tblIzvrsiteliBindingSource.Filter = " Sifra LIKE '%" + Sifra.Text + "%' and Ime + ' ' + Prezime LIKE '%" + Naziv.Text + "%' and RabotnoMesti LIKE '%" + RabtnoMesto.Text + "%'";
		}

		public override void IzbrisiZapis( object sender, EventArgs e ) {
			if ( this.tblIzvrsiteliGrid.CurrentRow != null ) {
				DialogResult opc;
				opc = MessageBox.Show( "Дали сте сигурни ?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question );
				if ( opc == DialogResult.Yes ) {
					this.tblIzvrsiteliGrid.Rows.Remove( tblIzvrsiteliGrid.CurrentRow );
					this.tableAdapterManager.UpdateAll( this.medicinskiUslugiDataSet );
				}
			}

			base.IzbrisiZapis( sender, e );
		}

		private void tblIzvrsiteliGrid_DataInsert() {
			this.tblIzvrsiteliTableAdapter.Fill( this.medicinskiUslugiDataSet.tblIzvrsiteli );
		}
	}
}